package com.market;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class SystemLogger {

	protected final Log log = LogFactory.getLog(this.getClass());

	@Pointcut("execution(* com.market.web.controller.OrderController.confirmCurrent(..))")
	public void orderConfirmCurrent() {

	}

	@Around("orderConfirmCurrent()")
	public void logEclipseTime(ProceedingJoinPoint joinpoint) {
		try {
			long t = System.currentTimeMillis();
			log.debug("Start time " + t);
			joinpoint.proceed();
			log.debug("Endt time " + System.currentTimeMillis());
			log.debug("Eclipse time " + (System.currentTimeMillis() - t));
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	@Pointcut("execution(* com.market.AspectJTest())")
	public void around() {

	}
	
	@Around("around")
	public void testAround(ProceedingJoinPoint joinpoint) throws Throwable{
		System.out.println("Before");
		joinpoint.proceed();
		System.out.println("After");
	}
	
}
